
<%@page import="Servlet.PMF"%>
<%@page import="com.google.appengine.api.datastore.Key"%>
<%@page import="DataAccess.UserAccess"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%@page import="java.util.List"%>
<%@page import="Entity.Account"%>
<%@page import="javax.jdo.PersistenceManager"%>
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/media/images/favicon.ico" />

		<title>Account Display</title>
		<style type="text/css" title="currentStyle">
			@import "../css/demo_page.css";
			@import "../css/demo_table.css";
                        @import "../css/main.css";
                        @import "../css/menu.css";
                        @import "../menu/menu_style.css";
                        .ui-widget{font-size:0.7em;}
                        .ui-helper-hidden-accessible{clip:auto;}
		</style>
                <script type="text/javascript" language="javascript" src="../js/jquery.js"></script>
                <script type="text/javascript" language="javascript" src="../js/jquery.dataTables.js"></script>
		<script type="text/javascript" charset="utf-8">
			var oTable;
			var giRedraw = false;
                        var ID;
			$(document).ready(function() {
				/* Add a click handler to the rows - this could be used as a callback */
				$("#example tbody").click(function(event) {
					$(oTable.fnSettings().aoData).each(function (){
						$(this.nTr).removeClass('row_selected');
					});
					$(event.target.parentNode).addClass('row_selected');
				});

				/* Add a click handler for the delete row */
				$('#delete').click( function() {
					var anSelected = fnGetSelected( oTable );
                                        //alert(anSelected[1]);
					oTable.fnDeleteRow( anSelected[0] );
				} );

				/* Init the table */
				oTable = $('#example').dataTable( );
			} );


			/* Get the rows which are currently selected */
			function fnGetSelected( oTableLocal )
			{
				var aReturn = new Array();
				var aTrs = oTableLocal.fnGetNodes();

				for ( var i=0 ; i<aTrs.length ; i++ )
				{
					if ( $(aTrs[i]).hasClass('row_selected') )
					{
						aReturn.push( aTrs[i] );
                                                ID = aTrs[i];
					}                                        
				}
                                
				return aReturn;
			}
                        function setEdit()
                        {
                            alert('Edit');
                            alert($(".row_selected .id").attr("align"));
                            var id = ID;
                            <% session.setAttribute("ID", ""); %>
                        }
                        function setDelete()
                        {
                            alert('Delete')
                           <% session.setAttribute("ID", "Delete"); %>
                        }
		</script>
                <script type="text/javascript" charset="utf-8">
                    
                </script>
</head>
<body>
    <%@include file="../headerAdmin.jsp" %>
    <div id="text">
            Danh sách người dùng
    </div>
    <div id="dt_example">

    <div id="container">
        <form action="/account" method="post">
            <input type="hidden" name="action" value="display">
            <input id="command" type="hidden" name="command" value=""/>
            <p><a href="javascript:void(0)" id="delete">Delete selected row</a></p>
            <div>
            <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
                <thead>
                  <tr>
                      <th>ID</th>
                   <th>Username</th>
                   <th>Full Name</th>
                   <th>Role</th>
                   <th>Sửa</th>
                   <th>Xóa</th>
                  </tr>
                 </thead>
                 <tbody>
                   <%
                        UserAccess user1 = new UserAccess();
                        List<Account> list;
                        list = user1.getListUser();
                        if (list.isEmpty() == false)
                            for(Account acc : list)
                            {
                  %>
                  <tr class="gradeA">
                    <td class="id" style="width: 75px" align="center"><% out.println(acc.getId()); %></td>
                    <td> <% out.println(acc.getUsername()); %></td>
                    <td> <% out.println(acc.getFullname()); %></td>
                    <td align="center" ><% out.println(acc.getRole()); %></td>
                    <td><a href="EditAccount.jsp?ID=<% out.print(acc.getId()); %>">Sửa</a></td>
                    <td><a href="DeleteAccount.jsp?ID=<% out.print(acc.getId()); %>">Xóa</a></td>
                  </tr>
                  <% } %>
                 </tbody>
            </table>
            </div>
        </form>
        </div>
    </div>
    </body>
</html>